package com.dragon.modules.yuegou.service.impl.lot;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.modules.yuegou.entity.lot.MemberTicketEntity;
import com.dragon.modules.yuegou.mapper.lot.MemberTicketMapper;
import com.dragon.modules.yuegou.model.lot.MemberTicket;
import com.dragon.modules.yuegou.query.lot.MemberTicketQuery;
import com.dragon.modules.yuegou.service.lot.MemberTicketService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 会员奖券信息表 服务实现
 *
 * @author pbuilder generated
 * @date 2019-10-24 10:22:55
 * @version 2.0
 */
@Service("lotMemberTicketService")
public class MemberTicketServiceImpl extends
		ServiceImpl<MemberTicketMapper, MemberTicketEntity> implements MemberTicketService {

	@Override
	public List<MemberTicket> lotteryCode(String id, String memberId) {
		MemberTicketQuery query = new MemberTicketQuery();
		query.setActivityId(id);
		query.setMemberId(memberId);
		QueryWrapper<MemberTicketEntity> wrapper = query.toQueryWrapper();
		wrapper.orderByDesc(MemberTicketEntity.COL_CREATED_TIME);
		return list(wrapper).stream().map(MemberTicket::new).collect(Collectors.toList());
	}

	@Override
	public List<MemberTicket> winningCode(String id) {
		MemberTicketQuery query = new MemberTicketQuery();
		query.setActivityId(id);
		query.setIsPrize(true);
		QueryWrapper<MemberTicketEntity> wrapper = query.toQueryWrapper();
		wrapper.orderByDesc(MemberTicketEntity.COL_CREATED_TIME);
		return list(wrapper).stream().map(MemberTicket::new).collect(Collectors.toList());
	}

}